//
//  ZLPCommentTableViewCell.m
//  TangYi
//
//  Created by dllo on 15/10/31.
//  Copyright © 2015年 赵连鹏. All rights reserved.
//

#import "ZLPCommentTableViewCell.h"

@implementation ZLPCommentTableViewCell

- (void)dealloc {
    [_picImageView release];
    [_nameLabel release];
    [_timeLabel release];
    [_commentLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    self.picImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.picImageView];
    self.picImageView.layer.cornerRadius = 20;
    self.picImageView.layer.masksToBounds = YES;
    [_picImageView release];
    
    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.nameLabel];
    [_nameLabel release];
    
    self.timeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.timeLabel];
    self.timeLabel.textColor = [UIColor grayColor];
    [_timeLabel release];
    
    self.commentLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.commentLabel];
    self.commentLabel.numberOfLines = 0;
    [_commentLabel release];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.picImageView.frame = CGRectMake(5, 5, 40, 40);
    self.nameLabel.frame = CGRectMake(50, 5, 300, 20);
    self.timeLabel.frame = CGRectMake(50, 25, 300, 20);
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:16], NSFontAttributeName, nil];
    
    CGRect rect = [self.commentLabel.text boundingRectWithSize:CGSizeMake(375, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.commentLabel.frame = CGRectMake(50, 50, self.contentView.frame.size.width - 80, rect.size.height + 20);

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
